package com.tianhui.consignortwofei.mvp.model;

import android.content.Context;

import com.fgs.common.CommonModel;
import com.fgs.common.api.CommonConfig;
import com.fgs.common.progress.ObserverResponseListener;
import com.tianhui.consignortwofei.api.OrderApiService;
import com.tianhui.consignortwofei.mvp.model.enty.BoHuiBodyBean;
import com.tianhui.consignortwofei.mvp.model.enty.GoodsInfo;

import java.util.Map;

import io.reactivex.ObservableTransformer;

/**
 * @author fgs
 * @date 2020/8/27
 * @description
 **/
public class GoodsModel<T> extends CommonModel<T> implements IDictionaryModel {


    /**
     * 发布货源
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void publishSourceModel(Context context, GoodsInfo info, boolean isDialog,
                                   ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).publishSource(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 发布询价货源
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void publishInquirySourceModel(Context context, GoodsInfo info, boolean isDialog,
                                          ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).publishInquirySource(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 发布询价货源
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void publishLiteSourceModel(Context context, GoodsInfo info, boolean isDialog,
                                       ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).publishLiteSource(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 发布询价货源(不开发票)
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void publishLiteSourceModelBukai(Context context, GoodsInfo info, boolean isDialog,
                                       ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).publishLiteSourceBukai(info), observerListener, transformer, isDialog, true);
    }


    /**
     * 保存路线信息
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void saveSourcePathInfoModel(Context context, Map<String, String> map, boolean isDialog,
                                        ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).sourcePathSave(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 车长吨位列表
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleLimitListModel(Context context, boolean isDialog,
                                      ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).vehicleLimitList(), observerListener, transformer, isDialog, true);
    }

    /**
     * 得到调度员用户信息根据货权信息
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void dispatcherListModel(Context context, boolean isDialog, Map<String, String> map,
                                    ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).dispatcherList(map), observerListener, transformer, isDialog, true);
    }

    @Override
    public void dictionaryModel(Context context, Map map, boolean isDialog, ObservableTransformer transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).dictionaryList(map), observerListener, transformer, isDialog, true);
    }


    /**
     * 找车单发货
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void sendFindCarList(Context context, GoodsInfo info, boolean isDialog,
                                       ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).sendFindCarList(info), observerListener, transformer, isDialog, true);
    }

//    /**
//     * 销售员名称
//     *
//     * @param context
//     * @param isDialog
//     * @param transformer
//     * @param observerListener
//     */
//    public void getXiaoShouName(Context context, GoodsInfo info, boolean isDialog,
//                                ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
//
//        //当不需要指定是否由dialog时，可以调用这个方法
//        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).sendFindCarList(info), observerListener, transformer, isDialog, true);
//    }


//    /**
//     * 驳回找车单
//     *
//     * @param context
//     * @param isDialog
//     * @param transformer
//     * @param observerListener
//     */
//    public void boHuiZhaoChe(Context context, Map<String, String> map, boolean isDialog,
//                                        ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
//
//        //当不需要指定是否由dialog时，可以调用这个方法
//        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).boHuiZhaoChe(map), observerListener, transformer, isDialog, true);
//    }

    /**
     * 找车单发货
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void boHuiZhaoChe(Context context, BoHuiBodyBean info, boolean isDialog,
                             ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).boHuiZhaoChe(info), observerListener, transformer, isDialog, true);
    }


    /**
     * 修改货权
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void changeHuoQuan(Context context, GoodsInfo info, boolean isDialog,
                                ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).changeHuoQuan(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 获取已发送重量
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void getAlreadySendWeight(Context context, Map<String, String> map, boolean isDialog,
                                        ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).getAlreadySendWeight(map), observerListener, transformer, isDialog, true);
    }

}
